/**
 * <p>动态复选框选择组</p>
 * xtype = cceafdynccheckboxgroup

 * @module Ext-ux-cceaf-control
 * @class cceaf.control.DyncCheckboxGroup
 * @extends Ext.form.CheckboxGroup
 * @since 1.0
 */
Ext.define('cceaf.control.DyncCheckboxGroup',{
	extend: 'Ext.form.CheckboxGroup', 
	requires: [
	    'cceaf.ControlDefaultConfig'
	],
    alias: 'widget.cceafdynccheckboxgroup',
	constructor: function(config){
		config = config || {};
        config = Ext.applyIf(config, {
        	columns: 6,
        	vertical: true
		});
		cceaf.control.DyncCheckboxGroup.superclass.constructor.apply(this, arguments);
	},
	load:function(url,params){
		var obj = this;
	    Ext.Ajax.request({  
	        url : url,  
	        method : 'POST',  
	        params:params,
	        success : function(form, action) {  
	            var json = Ext.JSON.decode(form.responseText);  
                if(json.success){
        		   if(json.message){
        			   obj.add({
    					   xtype: 'cceaflabel',
    					   html:'<font style="font-size:11px;">'+json.message+'</font>'
        			   });
        		   }else{
        			   for(var i=0;i<json.data.length;i++){
        				   var record = json.data[i];
        				   obj.add({
    						   boxLabel: record["text"], 
    						   xtype: 'checkboxfield',
    						   name:record["parameter"],
    						   inputValue: record["id"],
    						   id:record["parameter"],
    						   width:120,
    						   checked: record["checked"]
        				   });
        			   }
        			   
        		   }
        	   }else{
	        		   cceaf.util.ExtHelper.showInfoDialog(json.message);
        	   }
	        },  
	        failure : function(form, action) {  
	        	  cceaf.util.ExtHelper.showInfoDialog("网络中断，请稍后重试");
            }  
	    });
	},
	loadValue:function(url){
		var obj = this;
	  Ext.Ajax.request({  
	        url : url,  
	        method : 'POST',  
	        success : function(form, action) {  
	            var json = Ext.JSON.decode(form.responseText);  
                if(json.success){
            		for(var i=0;i<json.data.length;i++){
            			//检测节点  进行渲染
            			if(obj.queryById(json.data[i].name))
            				obj.queryById(json.data[i].name).setValue(true);
            		}
        	   }
	        },  
	        failure : function(form, action) {  
	        	  cceaf.util.ExtHelper.showInfoDialog("网络中断，请稍后重试");
            }  
	    });
	}
});